package com.four.controller;

import com.four.pojo.Coment;
import com.four.pojo.Staff;
import com.four.service.IComentService;
import com.four.service.IStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller("comentController")
public class ComentController {
    @Autowired
    @Qualifier(value = "comentService")
    private IComentService iComentService;
    @RequestMapping("/findAllComent")
    public String findAllComent(Model model){
        List<Coment> list=iComentService.findAllComent();;
        model.addAttribute("list",list);
        return "Comment.jsp";
    }
    @RequestMapping("findComent")
    public String findComent(Model model,String s){
        if (s.equals("全部评论")) {
            return "redirect:findAllComent";
        } else if (s.equals("好评")) {
            return "redirect:findHp";
        } else if (s.equals("差评")) {
            return "redirect:findCp";
        }
        return "";
    }

    @RequestMapping("findHp")
    public String findHp(Model model){
        List<Coment> list = iComentService.findHp();
        model.addAttribute("list" , list);
        return "Comment.jsp";
    }

    @RequestMapping("findCp")
    public String findCp(Model model){
        List<Coment> list = iComentService.findCp();
        model.addAttribute("list" , list);
        return "Comment.jsp";
    }

    @RequestMapping("findByIdComent")
    public String findByIdComent(Model model , int rid){
        Coment coment = iComentService.findByIdComent(rid);
        System.out.println(rid);
        model.addAttribute("coment" , coment);
        return "view_Comment.jsp";
    }
}
